package com.enzoism.springboot.fastjson.define;

import com.enzoism.springboot.fastjson.request.PeopleModel;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PasswordValidator implements ConstraintValidator<PasswordEqual, PeopleModel> {

    @Override
    public boolean isValid(PeopleModel peopleModel, ConstraintValidatorContext constraintValidatorContext) {
        String password1 = peopleModel.getPassword1();
        String password2 = peopleModel.getPassword2();
        // 这里只是做示例用，所以简单实用了equals进行对比，实际使用可以根据业务要求做更多拓展
        boolean match = password1.equals(password2);
        return match;
    }
}